//
//  SettingViewController.m
//  结伴
//
//  Created by wsl on 16/8/22.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "SettingViewController.h"

#import "NewsnoticeViewController.h"
#import "ModificationViewController.h"
#import "RecommendationViewController.h"
#import "FeedbackViewController.h"
#import "HighpraiseViewController.h"

#import "LoginViewController.h"

@interface SettingViewController ()

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"设置";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark 点击cell
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        //新消息通知
        NewsnoticeViewController *new  = [[NewsnoticeViewController alloc]init];
        [self.navigationController pushViewController:new animated:YES];
        
    }else if (indexPath.section == 1){
        if (indexPath.row == 0) {
            //修改密码
            ModificationViewController *new  = [[ModificationViewController alloc]init];
            [self.navigationController pushViewController:new animated:YES];

        }else{
            //清除缓存
        
            
            [MOAlertView showAlertWithTitle:@"清除成功" message:@"" buttonArrayAsString:@[@"确定"] finish:^(NSInteger num) {
                
                if (num == 0) {
                    
                    
                    
                }
                
            }];
            
          

        }
    }else if (indexPath.section == 2){
        if (indexPath.row == 0) {
            //推荐给好友
          
            RecommendationViewController *share = [[RecommendationViewController alloc]init];
            
            share.modalPresentationStyle = UIModalPresentationOverCurrentContext;
            
            
            [self presentViewController:share animated:YES completion:^{
                //        NSLog(@"展示完毕");
            }];


        }else if (indexPath.row == 1){
            //反馈
            FeedbackViewController *new  = [[FeedbackViewController alloc]init];
            [self.navigationController pushViewController:new animated:YES];

        }else{
            //给我们好评
            
            HighpraiseViewController *new  = [[HighpraiseViewController alloc]init];
            [self.navigationController pushViewController:new animated:YES];

        }
    }else{
        //退出当前账号
        
        
        [MOAlertView showAlertWithTitle:@"退出登录?" message:@"" buttonArrayAsString:@[@"取消",@"确定"] finish:^(NSInteger num) {
            
            if (num == 1) {
                
               LoginViewController *login  = [[LoginViewController alloc]init];
                MOKeyWindow.rootViewController = login;
            
                
            }
            
        }];
        

    }
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}



@end
